home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- main(argc,argv)
- int argc;
- char *argv[];
- {
- char c,s[256],z[256],e[256];
- int i,n,ss,es;
-
- if(argc!=4) { /* print help message */
- printf("midstr string start end\n returns the corresponding substring\n");
- printf("\n(C) Rainer Kowallik\n");
- }
-
- strcpy(s,argv[1]); /* source string */
- ss=atoi(argv[2]);
- es=atoi(argv[3]);
- midstr(e,s,ss,es);
- printf("%s\n",e);
- exit(0);
- }
-
-
- /* -------------------------------------------------
- return a substring from within a mainstring
- ------------------------------------------------- */
- midstr(substr,str,ss,es)
- char substr[],str[];
- short ss,es;
- { short i,j;
-
- i=0;
- for(j=ss; j <= es; j++) substr[i++]=str[j];
- substr[i]=0;
- }
-
-